Skip to content

Add rfl::cli::usage to generate usage and help text - #23

Open
clockblocker wants to merge 1 commit into
wave-base-5from
cli-usage-help-text
Open

clockblocker wants to merge 1 commit into
wave-base-5from
cli-usage-help-text

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Implements munich-data-engineering/reflect-cpp#692: adds rfl::cli::usage<T, Ps...>(program_name, detailed) to generate usage lines and aligned help text directly from a struct definition.

Example

enum class LogLevel { debug, info, warn };
struct Database { std::string host; int port; };
struct Config {
  rfl::Description<"Input file", rfl::Positional<std::string>> input_file;
  rfl::Short<"p", rfl::Description<"Port", int>> port;
  bool verbose;
  std::vector<std::string> tags;
  Database database;
  std::optional<LogLevel> log_level;
};

// Compact usage (detailed = false):
rfl::cli::usage<Config>("my_binary").value();
// Usage: my_binary <input-file> -p|--port=<value> --verbose[=<bool>] --tags=<v1,v2,...> --database.host=<value> --database.port=<value> [--log-level=<debug|info|warn>]

// Detailed help (detailed = true) adds aligned rows:
// Arguments:
//   <input-file>                Input file. Required.
//   -p, --port=<value>          Port. Required.
//   --verbose[=<bool>]          Required.
//   ...

Key details

AI-authored. Depends on: #21, #33, #34.

rfl::cli::usage<T, Ps...>(program_name, detailed = false) returns the
one-line usage form for the struct that rfl::cli::read<T, Ps...> parses
into, and with detailed = true one row per argument: description, enum
choices of positional arguments, and "Required.". It returns an
rfl::Result<std::string>, with an error where no read of T can succeed.

It walks the format-agnostic schema (rfl::parsing::schema::make) and
takes positionals, short aliases and flags from the parser's option
table, and requiredness from the same traits as the parser, so the help
matches what read accepts.

Implements munich-data-engineering#692.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant